package com.hospital.patient.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.common.domain.patient.Department;
import com.hospital.common.exceptions.ServiceException;
import com.hospital.common.utils.ExtractUtil;
import com.hospital.patient.mapper.DepartmentMapper;
import com.hospital.patient.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Author：sjc
 * @Description:
 * @name：DepartmentServiceImpl
 * @Date：2024/10/20 16:19
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;


    @Override
    public List<Department> findDepartment(String str) {
        //根据患者面熟试提取关键词
        String extract = ExtractUtil.extract(str);
        if("请详细描述您的病状".equals(extract)){
            throw new ServiceException(extract);
        }
        if("您好,请详细描述您的病状,格式为:我最近腿疼,腰疼得厉害，还伴有脚气伴有糜水泡烂.".equals(extract)){
            throw new ServiceException(extract);
        }
        Department department = new Department();
        department.setDescription(extract);
        //根据关键词查询
        List<Department> departments = departmentMapper.selectList(new QueryWrapper<Department>().lambda()
                .like(Department::getDescription, extract));
        return departments;
    }
}
